package com.dp.appi.util.alipay2.util;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * Created by chenghao on 2016/8/12.
 */
public class AliUtil {
    public static Map<String, String> getAliResult(Map requestParams){
        //获取支付宝POST过来反馈信息
        Map<String,String> params = new HashMap<>();
        for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
            String name = (String) iter.next();
            String[] values = (String[]) requestParams.get(name);
            String valueStr = "";
            for (int i = 0; i < values.length; i++) {
                valueStr = (i == values.length - 1) ? valueStr + values[i] : valueStr + values[i] + ",";
            }
            //乱码解决，这段代码在出现乱码时使用。如果mysign和sign不相等也可以使用这段代码转化
            //valueStr = new String(valueStr.getBytes("ISO-8859-1"), "gbk");
            params.put(name, valueStr);
        }
        return params;
    }
}
